
const user = {
    namespaced: true, // 命令空间
	// 内存
	state: {
		user: {}, //用户信息
	},
	/**
	 * 只能定义同步任务
	 */
	mutations: {
		//state:状态,后面的参数是传入的参数
		SAVE_USER(state, user) {
			state.user = user
		},
		CLEAR_USER(state) {
			state.user = {}
		},
	},
	/**
	 * actions可以定义异步任务
	 */
	actions: {
		//commit 执行mutations中方法, 后面的参数为传的参数
		saveUser({ commit }, user) {
			commit('SAVE_USER', user)
		},
		clearUser({ commit }) {
			commit('CLEAR_USER')
		},
	},
	getters: {
		user: state => state.user,
	},
	
}

export default user
